import { Injectable } from '@nestjs/common';
import {Repository} from 'typeorm'
import {InjectRepository} from '@nestjs/typeorm'
import {UserEntity} from './user.entity'
@Injectable()
export class UserService {
  constructor(
    @InjectRepository(UserEntity)
    private  userRepository:Repository<UserEntity>
  ){}

  async userById(id){
    const result = await this.userRepository.findOne(id)
    console.log('result',result);
    
    return result
  }

  async createUser(data){
    try {
      await this.userRepository.save(data)
    return '创建成功'
    } catch (e) {
      return e
    }
  }
}
